package com.xmim.core;

import com.xmim.core.session.DefaultSessionPipeline;
import com.xmim.core.session.SessionHandle;
import com.xmim.core.session.SessionHandleContext;
import com.xmim.core.session.SessionPipeline;
import org.junit.Test;

public class PipelineDemo {

    @Test
    public void testPipeline() {
        SessionPipeline sessionPipeline = new DefaultSessionPipeline(null);
        sessionPipeline.add("aaa", new SessionHandle() {
            @Override
            public void handleAdded(SessionHandleContext ctx) throws Exception {
                System.out.println("111111");
                ctx.fireAdded();
            }
        });
        sessionPipeline.add("bbb", new SessionHandle() {
            @Override
            public void handleAdded(SessionHandleContext ctx) throws Exception {
                System.out.println("22222");
                ctx.fireAdded();
            }
        });
        sessionPipeline.add("ccc", new SessionHandle() {
            @Override
            public void handleAdded(SessionHandleContext ctx) throws Exception {
                System.out.println("33333");
                ctx.fireAdded();
            }
        });
        sessionPipeline.add("ddd", new SessionHandle() {
            @Override
            public void handleAdded(SessionHandleContext ctx) throws Exception {
                System.out.println("44444");
                ctx.fireAdded();
            }
        });
        try {
            sessionPipeline.fireAdded();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
